<template>
  <div class="header">
    <!-- 返回箭头 -->
    <div class="header_arrow" @click="goBack">
      <slot name="header_arrow">
        <img :src="imgSrc" alt="" slot="header_arrow" />
      </slot>
    </div>
    <!-- 中间标题问题 -->
    <div class="header_title">
      <slot name="header_title">
        <span>{{ title }}</span>
      </slot>
    </div>
    <!-- 文字与图标 -->
    <div class="header_icon">
      <slot name="header_icon">
        <span>{{ text }}</span>
      </slot>
    </div>
  </div>
</template>
 
<script>
export default {
  name: "Header",
  props: {
    title: {
      type: String,
    },
    imgSrc: {
      type: String,
    },
    text: {
      type: String,
    },
  },
  methods: {
    // 返回上一页
    goBack() {
      this.$router.back(-1);
    },
  },
};
</script>
<style lang="less">
.header {
  width: 100%;
  height: 45px;
  background-color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
}
// 左中右布局, 直接给中间的盒子设置flex:1;
.header .header_title {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  font-size: 16px;
  color: #333;
  font-weight: 700;
//   margin-left: -5%;
//   margin-right: -20%;
}
.header_arrow {
  display: flex;
  justify-content: center;
  align-items: center;
}
.header_arrow img {
//   width: 5%;
  width: 30px;
}
.header_arrow img {
  vertical-align: middle;
}
.header_icon {
//   width: 20%;
  font-size: 14px;
  color: #115ffb;
  padding: 5px 8px;
}
</style>